<template>
  <div :class="className" :style="wrapper_style">
    <!-- 任务包组件 -->
    <div style="background-color: #fff;padding: 10px;border-radius: 4px;">
      <div class="videoList">
        <div class="videoLis" v-for="(item, index) in videoArr" :key="index">
          <div class="status" v-if="item.status">已完成</div>
          <div class="status_no" v-if="!item.status">未完成</div>
          <div class="line" :class="checkBackground(index, item, videoArr)">
            <div class="img">
              <img
                src="../../../resource/images/taskPackage/video@2x.png"
                v-if="item.status"
                alt=""
              />
              <img
                src="../../../resource/images/taskPackage/video1@2x.png"
                v-if="!item.status"
                alt=""
              />
            </div>
          </div>
          <div :class="!item.status ? 'name_default' : ''" class="name">
            {{ item.name }}
          </div>
        </div>
      </div>
      <div class="videoList">
        <div class="videoLis" v-for="(item, index) in shareVideoArr" :key="index">
          <div class="status_pyq" v-if="item.status">已完成</div>
          <div class="status_no" v-if="!item.status">未完成</div>
          <div class="line" :class="checkBackground(index, item, shareVideoArr)">
            <div class="imgpyq">
              <img
                src="../../../resource/images/taskPackage/pyq@2x.png"
                v-if="item.status"
                alt=""
              />
              <img
                src="../../../resource/images/taskPackage/pyq1@2x.png"
                v-if="!item.status"
                alt=""
              />
            </div>
          </div>
          <div :class="!item.status ? 'name_default' : ''" class="name_pyq">
            {{ item.name }}
          </div>
        </div>
      </div>
      <div class="videoList">
        <div class="videoLis" v-for="(item, index) in videoArr" :key="index">
          <div class="status_share" v-if="item.status">已完成</div>
          <div class="status_no" v-if="!item.status">未完成</div>
          <div class="line" :class="checkBackground(index, item, videoArr)">
            <div class="imgShare">
              <img
                src="../../../resource/images/taskPackage/fx@2x.png"
                alt=""
                v-if="item.status"
              />
              <img
                src="../../../resource/images/taskPackage/fx1@2x.png"
                alt=""
                v-if="!item.status"
              />
            </div>
          </div>
          <div :class="!item.status ? 'name_default' : ''" class="name_share">
            {{ item.name }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      videoArr: [
        {
          status: true,
          name: "视频1",
          id: 1,
        },
        {
          status: true,
          name: "视频2",
          id: 2,
        },
        {
          status: true,
          name: "视频3",
          id: 3,
        },
        {
          status: true,
          name: "视频4",
          id: 4,
        },
        {
          status: true,
          name: "视频5",
          id: 5,
        },
        {
          status: true,
          name: "视频6",
          id: 6,
        },
        {
          status: true,
          name: "视频7",
          id: 7,
          last: true,
        },
        {
          status: false,
          name: "视频8",
          id: 8,
        },
      ],
      shareVideoArr: [
        {
          status: true,
          name: "分享视频1",
          id: 1,
        },
        {
          status: true,
          name: "分享视频2",
          id: 2,
        },
        {
          status: true,
          name: "分享视频3",
          id: 3,
          last: true,
        },
        {
          status: false,
          name: "分享视频4",
          id: 4,
        },
      ],
    };
  },
  props: ["id", "datas", "styles"],
  computed: {
    css() {
      return "<style>" + css.call(this) + "</style>";
    },
    className() {
      const name = ["component-wrapper", `component-${this.id}`];
      return name;
    },
    wrapper_style() {
      if (this.datas.preview_color) {
        const { preview_color } = this.datas;

        return `
                width: 100%;
                background-color: ${preview_color.color};
                background-image: url(${
                  preview_color.isColor == 2 ? preview_color.image : ""
                });
                background-size: 100% 100%;
                bakcground-position: center;
            `;
      }
    },
  },

  methods: {
    checkBackground(index, item, arr) {
      if (item.status) {
        if (item.last) {
          if (index == arr.length - 1) {
            return "lineSelect_all";
          }
          return "lineSelect";
        } else {
          return "lineSelect_all";
        }
      }
    },
  },

  mounted() {},
};
</script>

<style lang="less" scoped>
// 默认
.component-wrapper {
  width: 375px;
  padding: 12px;
}
.videoList::-webkit-scrollbar {
  width: 0px;
}
.videoList:last-child {
  margin-bottom: 0;
}
.videoList {
  display: flex;
  overflow-x: scroll;
  margin-bottom: 14px;
  .videoLis:last-child {
    padding-right: 14px;
  }
  .videoLis:first-child {
    padding-left: 14px;
  }
  .videoLis:first-child .line {
    border-radius: 3px 0 0 3px;
  }
  .videoLis:last-child .line {
    border-radius: 0 3px 3px 0;
  }
  .videoLis {
    position: relative;
    flex-shrink: 0;
    width: 20%;
    display: flex;
    flex-direction: column;
    align-items: center;
    .status {
      font-size: 10px;
      font-weight: 400;
      color: #f55e55;
      line-height: 10px;
    }
    .status_pyq {
      font-size: 10px;
      font-weight: 400;
      color: #07c160;
      line-height: 10px;
    }
    .status_share {
      font-size: 10px;
      font-weight: 400;
      color: #29abe2;
      line-height: 10px;
    }
    .status_no {
      font-size: 10px;
      font-weight: 400;
      color: #9a9a9a;
      line-height: 10px;
    }
    .lineSelect {
      background: linear-gradient(
        to right,
        #f55e55 0%,
        #f55e55 50%,
        #e6e6e6 51%,
        #e6e6e6 100%
      ) !important;
    }
    .lineSelect_all {
      background: #f55e55 !important;
    }

    .line {
      width: 100%;
      height: 5px;
      background: #e6e6e6;
      margin: 14px 0 15px 0;
      display: flex;
      align-items: center;
      justify-content: center;
      .imgpyq {
        width: 20px;
        height: 20px;
        border-radius: 100%;
        img {
          width: 20px;
          height: 20px;
          border-radius: 100%;
          display: flex;
        }
      }
      .imgShare {
        width: 20px;
        height: 20px;
        img {
          width: 20px;
          height: 20px;
          display: flex;
        }
      }
      .img {
        width: 22px;
        height: 16px;
        img {
          width: 22px;
          height: 16px;
          display: flex;
        }
      }
    }

    .name {
      font-size: 12px;
      font-weight: 400;
      color: #f55e55;
    }
    .name_pyq {
      font-size: 12px;
      font-weight: 400;
      color: #07c160;
    }
    .name_share {
      font-size: 12px;
      font-weight: 400;
      color: #29abe2;
    }
    .name_default {
      color: #000;
    }
  }
}
</style>
